<?php
declare (strict_types = 1);
namespace app\course\model\base;

use app\common\model\BaseModel;
use app\school\model\school\School;
use think\model\concern\SoftDelete;
use think\model\relation\BelongsTo;

/**
 * 购物车模型
 */
class CourseCart extends BaseModel
{
    use SoftDelete;
    /**
     * 表名
     * @var string
     */
    protected $name = 'course_cart';
    /**
     * 隐藏课时数据
     * @var [type]
     */
    protected $hidden = ['update_time','delete_time'];

    /**
     * 定义字段类型
     * @var array
     */
    protected $type = [
        'id'          => 'integer',
        'user_id'     => 'integer',
        'course_id'   => 'integer',
        'create_time' => 'integer',
        'update_time' => 'integer'
    ];

    /**
     * 课程
     * Author   亓官雨树<lucky.max@foxmail.com>
     * Date 2020-04-27
     *
     * @return BelongsTo [type]                      [description]
     */
    public function course(): BelongsTo
    {
        return $this->belongsTo(Course::class,'course_id');
    }

    /**
     * 课程
     * Author   亓官雨树<lucky.max@foxmail.com>
     * Date 2020-04-27
     *
     * @return BelongsTo [type]                      [description]
     */
    public function school(): BelongsTo
    {
        return $this->belongsTo(School::class)->bind(['school_name' => 'mhm_id']);
    }

}
